package obecto.task.animation
{
	import obecto.task.BaseTask;
	import obecto.task.MultiTargetTask;
	import obecto.utility.CloneUtility;

	[DefaultProperty("prototypeTask")]
	public class MultiTargetTweenAnimation extends MultiTargetTask
	{
		override protected function clonePrototype(target : Object) : BaseTask
		{
			var result : PropertiesTweenAnimation = super.clonePrototype(target) as PropertiesTweenAnimation;
			result.tweeningProperties = cloneTweeningProperties(PropertiesTweenAnimation(prototypeTask).tweeningProperties);
			result.target = target;
			return result;
		}
		
		protected function cloneTweeningProperties(tweeningProperties : Array) : Array
		{
			var result : Array = [];
			for each (var tweenProperty : TweenProperty in tweeningProperties)
			{
				var clone : TweenProperty = new TweenProperty();
				clone.name = tweenProperty.name;
				clone.startValue = tweenProperty.startValue;
				clone.endValue = tweenProperty.endValue;
				
				result.push(clone);
			}
			return result;
		}
		
	}
}